package com.wy2.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

//解决跨域的配置类
//继承WebMvcConfigurerAdapter
@Configuration
public class CorsConfig extends WebMvcConfigurerAdapter {
	/**
	 * 注册请求地址
	 * 重写 addCorsMappings
	 */
	public void addCorsMappings(CorsRegistry registry) {
		//设值可以跨域请求的方法allowedMethods()
		//restfull风格里的方法："GET","POST","PUT","DELETE" (注意：大写)
		registry.addMapping("/**")
		.allowedMethods("GET","POST","PUT","DELETE");
	}
	
}
